import router from './router/index'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
// NProgress是封装的进度条
NProgress.configure({ showSpinner: false })

// 路由拦截器
router.beforeEach(async (to, from, next) => {
    NProgress.start()
    console.log(to)
    // 外链跳转 (这个方法的缺点是中断路由，element框架会在控制台外露出一个abort的错误)
    // if (to.path.includes('http')) {
    //     window.open(to.path.substring(1))
    //     next(false)
    //     NProgress.done()
    //     return
    // } 
    next()
})

router.afterEach(() => {
    NProgress.done()
})
